package lesson1;

public class Person {
    private String name;
    private int age;
    private String sex;

    public void eat(){
        System.out.println("啥都吃...");
    }
    public Person(){

    }

    public Person(String name){
        this.name = name;
    }

    public Person(int age,String sex){
        this.age = age;
        this.sex = sex;
    }

    public Person(String name,int age,String sex){
        //构造方法只能通过new调用
        //只能在构造方法中通过this/super关键字调用别的构造方法,并且只能写在第一行
        this(age,sex);
        this.name = name;

    }



    public String getName() {
        return this.name;
    }

    //
    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return this.age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    void fun1(){

    }

    void fun2(){
        this.fun1();
    }

    //只要两个对象姓名、性别、年龄全部相同就认为两个Person对象相同

    /**
     * 比较两个Person对象是否一致
     * @param person 要比较的Person对象
     * @return 一致 true  不一致 false
     */
    public boolean isEquals(Person person){
        //
        if(this == person){
            return true;
        }
        if(name.equals(person.name) && age == person.age && sex.equals(person.sex)){
            return true;
        }
        return false;
    }
}
